package com.aaa.dem1027.第二遍.d03;

import java.lang.reflect.Method;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/10/27  15:20
 */
public class test1 {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("com.aaa.dem1027.d12.teacher");

        Method fun = aClass.getDeclaredMethod("fun");

        Object o = aClass.newInstance();
        Object invoke = fun.invoke(o);
        System.out.println("invoke = " + invoke);

        Method cun = aClass.getDeclaredMethod("cun", String.class, Integer.class);
        Object invoke1 = cun.invoke(o, "汪豪杰", 22);
        System.out.println("invoke1 = " + invoke1);
    }
}

class student{
    public void eat(){
        System.out.println("吃饭");
    }
    public void run(){
        System.out.println("跑步");
    }
}

class teacher extends student{
    public void fun(){
        System.out.println("teacher的fun");
    }
    public String cun(String name,Integer age){
        System.out.println("teacher的cun"+name);
        return "汪豪杰真帅";
    }
}
